package ws

import "time"

type SessionIdleTimeout struct {
	session *Session
}

func (x *SessionIdleTimeout) OnTimeout() {
	x.session.sessionHandle.OnIdleTimeout(x.session)
}

func (x *SessionIdleTimeout) IsTimeout() bool {
	return x.session.lastActiveAt.Add(x.session.idleTimeout).Before(time.Now())
}

func NewSessionIdleTimeout(session *Session) *SessionIdleTimeout {
	return &SessionIdleTimeout{
		session: session,
	}
}
